<?php

/** 
* 
* 
* by:南宁火蝶科技有限公司 http:///www.HdsysCms.com
* 声明:本系统禁止用二次开发、侵犯HdsysCms著作和除去HdsysCms进行售卖,如发现将追究一切权利,模版制作属于自己所得可以通过本系统对外开发模版获取收益!
* 
* 2019年第一版本发布 - 到2023.9.1开源使用! 
* php混淆工具:phpencry.wbox.top
* 
* 注意防骗:@HdsysCms 官方没授权任何个人机构合作,唯一收款抬头:《南宁火蝶科技有限公司》和官网显示客服唯一渠道客服,其它渠道以HdsysCms名义行为均骗子!
*
*/
	

defined('HDSYS_SET') or die("".'Not,This File Not Can in Ie Open');
class db
{
public $intelligence_connect_db,$intelligence_connect_sql;
public  function intelligence_cache_array($param_sql)
{
$param_md5=md5($param_sql);
$param_array=templates::GetFileArrayCodeCache('Mysql_Cache_Array_' . $param_md5);
if ($param_array==false) {
$param_while_array_list_all=$this->intelligence_connect_db->intelligence_array($param_sql);
if(!$param_while_array_list_all){
$param_while_array_list_all=array();
}
return include(templates::PushFileArrayCodeCache('Mysql_Cache_Array_' . $param_md5, $param_while_array_list_all));
} else {
return include($param_array);
}
}
public function __construct()
{
$this->intelligence_connect();
}
public function intelligence_connect()
{
if (DBSQLTYPE=='mysql') {
include_once(HDSYS_DIR_LIB . '/class/mysql.class.php');
$this->intelligence_connect_db=new mysql();
} elseif (DBSQLTYPE=='sqlite') {
include_once(HDSYS_DIR_LIB . '/class/sqlite.class.php');
$this->intelligence_connect_db=new sqlite();
} else {
die('sql linke set mysql/sqlite in sql.cinfig.php');
}
}
public function intelligence_assoc($param_sth)
{
return $this->intelligence_connect_db->intelligence_fetch($param_sth);
}
public function intelligence_is_table($param_table)
{
return $this->intelligence_connect_db->intelligence_is_table($param_table);
}
public function intelligence_getinsert_id()
{
return $this->intelligence_connect_db->intelligence_getinsert_id();
}
public function intelligence_insert_one($tablename, $arr)
{
$set_a=' (';
$set_b=' VALUES(';
foreach ((array )$arr as $k=> $v) {
$set_a .='`' . $k . '`, ';
$set_b .='\'' . $v . '\', ';
}
$set_a=substr($set_a, 0, -2);
$set_b=substr($set_b, 0, -2);
$set_a .=')';
$set_b .=')';
$param_sql='INSERT INTO `' . $tablename.'`' . $set_a.$set_b.';';
return $this->intelligence_connect_db->intelligence_query($param_sql);
}
public function intelligence_insert($tablename, $arr)
{
return $this->intelligence_insert_one($tablename, $arr);
#sqlite 不支持
}
public function intelligence_update($tablename, $arr, $where)
{
$set='';
foreach ((array )$arr as $k=> $v) {
$set .='`' . $k . '`=\'' . $v . '\', ';
}
$set=substr($set, 0, -2);
$param_sql='UPDATE `' . $tablename . '` SET ' . $set .' where '. $where;
return $this->intelligence_connect_db->intelligence_query($param_sql);
}
public function intelligence_query($param_sql)
{
$this->intelligence_connect_sql=$param_sql;
$param_sql=call_my_str_replace('hdsys_',DBQIANHUAN,$param_sql);
return $this->intelligence_connect_db->intelligence_query($param_sql);
}
public function intelligence_sql()
{
return $this->intelligence_connect_db->intelligence_sql();
}
public function intelligence_exec($param_sql)
{
$param_ini=$this->intelligence_connect_db->exec($param_sql);
return $param_ini;
}
public function intelligence_rc_rows($param_PDOStatement)
{
return $this->intelligence_rows($param_PDOStatement);
}
public function intelligence_rows($param_PDOStatement)
{
if (is_object($param_PDOStatement)) {
$param_rows=$param_PDOStatement->rowcount();
return $param_rows;
} else {
return call_my_int_0();
}
}
public function intelligence_array($param_sql)
{
return $this->intelligence_connect_db->intelligence_array($param_sql);
}
}
